#!/user/bin/env jython
# -*- coding: utf-8 -*-

from javax.swing import *
from java.awt import *
from java.lang import *


class JStartTask:
	
	def __init__(self, panel):
		
		
		self.mainPanel = panel
		
		
		
		self.makeTopPanel()
		self.addLabelToTop()
		self.addMidleGrid()
		
		print "ola"
		
		pass
		
	def makeTopPanel(self):
		
		self.topPanel = JPanel()
		self.topPanel.setPreferredSize(Dimension(800,50))
		self.topPanel.setMinimumSize(Dimension(800,50))
		self.topPanel.setMaximumSize(Dimension(800,50))
		self.topPanel.setBackground(Color.ORANGE)
		self.topPanel.layout = FlowLayout(FlowLayout.CENTER)
		self.mainPanel.add(self.topPanel)
		
	def addLabelToTop(self):
		
		topTitle = JLabel()
		topTitle.setText("Ups, no database found")
		topTitle.setFont(Font("Arial", Font.BOLD, 32));
		self.topPanel.add(topTitle)
		
	def addMidleGrid(self):
		
		auxPanel1 = JPanel()
		auxPanel1.setMaximumSize(Dimension(800, 200))
		auxPanel1.setPreferredSize(Dimension(800, 200))
		self.mainPanel.add(auxPanel1)
		################################################
		midlePanel = JPanel()
		midlePanel.layout = FlowLayout(FlowLayout.CENTER)
		midlePanel.setMaximumSize(Dimension(800, 50))
		
		title1 = JLabel()
		title1.setText("<html><center>Unfortunately the database required"
		 + " to that program, was not created yet.<br>" + 
		"You want create database now?</center></html>")
		
		title1.setFont(Font("Arial", Font.BOLD, 18));
		midlePanel.add(title1)
		
		
		#################################################
		bottomPanel = JPanel()
		bottomPanel.layout = BoxLayout(bottomPanel, BoxLayout.Y_AXIS)
		
		endPanel = JPanel()
		endPanel.setMaximumSize(Dimension(800, 50))
		endPanel.layout = FlowLayout(FlowLayout.CENTER)
		#################################################
		createButton = JButton("Create database", actionPerformed = self.createDatabase)
		cancelButton = JButton("Not now", actionPerformed = self.exitProgram)
		
		endPanel.add(createButton)
		endPanel.add(cancelButton)
		
		bottomPanel.add(endPanel)
		
		
		
		self.mainPanel.add(midlePanel)
		self.mainPanel.add(bottomPanel)
	
	
	def createDatabase(self, event):
		print self.mainPanel.getHeight()
		print self.mainPanel.getWidth()
		print "######################"
		
	def exitProgram(self, event):
		System.exit(0)
